# !python3      # 使用工具:PyCharm
# 用户登录名:yyds_l
# 项目名称: python爬虫     文件名称:001_python_获取抖音热度榜数据
# 创建日期:2022/3/27      创建时间:15:17
# 2022/03/27 15:17


# 运行
if __name__ == '__main__':
    import urllib.request
    from lxml import etree
    url = 'https://www.cnblogs.com/gfweb/p/11118882.html'
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'
                      ' AppleWebKit/537.36 (KHTML, like Gecko)'
                      ' Chrome/92.0.4515.159 Safari/537.36'
    }
    res = urllib.request.Request(url=url, headers=headers)
    html = urllib.request.urlopen(res)
    html=html.read().decode('utf-8')
    # print(html)
    tree = etree.HTML(html)

    img = tree.xpath("//pre/text()")
    print(img)
    # for i in range(0, len(img)):
    #     print(img[i])
    # print(type(img))
